1. Field of the Invention
The present invention relates to an image coding apparatus, an image coding method and an apparatus for storing/transmitting image. More specifically, the present invention relates to an image coding apparatus for converting image information to variable length code of predetermined code size by compression, method of image coding and apparatus for storing/transmitting image.
2. Description of the Background Art
A variable length coding method proposed by JPEG (Joint Photographic Experts Group) has been known as a method of compressing image data. Though high compression ratio is possible by this method, the amount of codes after compression varies dependent on the content of the original image. Therefore, the amount of codes after compression is made constant in the following manner in such a field in that it is necessary to make constant the amount of codes after compression (for example, in the field of electronic still camera where a prescribed number of images must be picked up and recorded regardless of the content of the object).
FIG. 23 is a block diagram showing a structure of such a conventional electronic still camera. Referring to FIG. 23, the electronic still camera includes an image capture device 51, an image processing unit 52, an image memory 53, a JPEG encoder 54, code size measuring unit 55, compression coefficient estimating unit 56 and a recording device 57.
Image pickup device 51 includes a lens, a CCD and the like, and it converts an image of an object to an analog image signal. Image processing unit 52 performs various processes on analog image signal output from image capture device 51 and thereafter converts it to digital image data. Image memory 53 temporarily stores the digital image data generated by image processing unit 52.
JPEG encoder 54 includes a DCT unit 61, a quantization table storing unit 62, a multiplier 63, a quantizing unit 64 and a coding unit 65.
DCT unit 61 divides the original image into a plurality of pixel blocks each consisting of 8.times.8 pixels, and represents image data of each pixel block as a matrix consisting of pixel data of 8 rows.times.8 columns as shown in FIG. 25A, for example. Each pixel data represents image density of the corresponding pixel in 256 tones (8 bits=1 byte). DCT unit 61 performs two-dimensional DCT (Discrete Cosine Transformation) using equation (1) below on the matrix of each pixel block, providing a matrix expression of DCT coefficients in 8 rows.times.8 columns as shown in FIG. 25B. ##EQU1##
(x, y, u, v: integer form 0 to 7)
In quantization table storing unit 62, a quantization table including threshold values of 8 rows and 8 columns as exemplified in FIG. 25C is stored. Multiplier 63 multiplies threshold value for quantization of 8 rows and 8 columns output from quantization table storing unit 62 by a certain coefficient (hereinafter referred to as compression coefficient).
Quantizing unit 65 divides the corresponding DCT coefficient by each threshold value of the quantization table applied from multiplier 63 as shown in FIG. 25D, and converts the result to a closest integer. Coding unit 65 encodes the quantized DCT coefficient block by block in accordance with Huffman coding method, and generates compressed data.
At this time, the larger the threshold for quantization, the narrower the bit width of the quantized value, which means that the amount of information is reduced and compression ratio is increased (the amount of codes after compression becomes smaller). However, the degree of degradation of image quality is higher. In contrast, the smaller the threshold value for quantization, the lower the compression ratio (the amount of codes after compression is larger), while the degree of degradation of image quality is suppressed. Utilizing this nature, it is possible to control relation between image quality and the amount of codes by storing basic quantization table in quantization table storing unit 62 and controlling threshold value for quantization by reorganizing the quantization table by multiplying compression coefficient.
Returning to FIG. 23, code size measuring unit 55 measures amount of data (amount of codes) of compressed data which have been converted to JPEG codes by JPEG encoder 54. Compression coefficient estimating unit 56 performs the following processings. In the first processing, a compression coefficient s1 is estimated by which amount of codes of the compressed data is made smaller than a predetermined target amount Qx of codes. In the second processing, contrary to the first processing, a compression coefficient s2 is estimated by which the amount of codes of the compressed data is made larger than the target code size Qx. In the third processing, an optimal compression ratio sx by which compressed data comes to have the target code size Qx is estimated, based on the result of measurement of code size when JPEG is performed using the aforementioned two compression coefficients s1 and s2.
As an example of the method of estimating compression coefficient sx, there is a method of estimating linearly as shown in FIG. 26. More specifically, code size after preencoding when compression coefficient is s1 is represented as Q1, code size after preencoding when compression coefficient is s2 is represented as Q2, and compression coefficient when the target code size Qx is attained is represented as xs. Assuming that the compression coefficient and the code size have linear relation, the coefficient sx can be calculated in accordance with the following equation . EQU sx=s1-(s1-s2)(Qx-Q1)/(Q2-Q1) (2)
Finally, the code data compressed to the target code size Qx is transferred to recording apparatus 57 and stored at a prescribed address of a recording medium.
FIG. 27 is a flow chart showing the operation of the electronic still camera in accordance with constant sized coding control using JPEG coding method. The operation of the electronic still camera shown in FIGS. 23 to 26 would be briefly described with respect to the flow chart.
An image of an object is converted to an analog image signal by image capture device 51, the analog image signal is converted to digital image data by image processing unit 52 and stored in image memory 53. The image data taken out from image memory 53 is applied to JPEG encoder 54.
In step S71, compression coefficient estimating unit 56 applies a relatively high compression ratio s1 to JPEG encoder 54 for preencoding operation 1 so that compression ratio is higher than the optimal value, or code size of the compressed data is smaller than target code size Qx, and code size measuring unit 55 measures code size Q1 of the compressed data.
Thereafter, in step S72, compression coefficient estimating unit 56 applies a relatively low compression ratio s2 to JPEG encoder 54 for preencoding operation 2, such that compression ratio becomes lower than the optimal value, or the code size of compressed data is larger than the target code size Qx, and code size measuring unit 55 measures the code size of the compressed data.
Thereafter, in step S73, compression coefficient estimating unit 56 estimates a compression coefficient by which optimal compression ratio is obtained, that is, by which the code size of the compressed data attains the target code size Qx, based on the result of two preencoding operations 1 and 2, applies the estimated compression coefficient sx to JPEG encoder 54 for encoding. The image data compressed to the target code size Qx is transferred to recording apparatus 57 and stored at a prescribed address of the recording medium.
However, in the conventional electronic still camera shown in FIGS. 23 to 27, JPEG compression must be performed a total of three times on the image data in order to compress the image data to the target code size Qx, which means that the necessary time is third times that required for one compression, and hence data compression takes much time.
FIG. 28 is a block diagram showing a structure of another conventional electronic still camera. Referring to FIG. 28, the electronic still camera differs from the one of FIG. 23 in that code size measuring unit 55 and compression coefficient estimating unit 56 are removed, while an edge intensity calculating unit 70 and compression coefficient estimating unit 71 are newly provided.
Edge intensity calculating unit 70 calculates a parameter E representing edge intensity, based on the image data read from image memory 53. The parameter E, the compression coefficient and the code size of the compressed data are correlated with each other. Compression coefficient estimating unit 71 estimates, based on the parameter E applied from edge intensity calculating unit 70 and on the aforementioned correlation, compression coefficient sx for compressing the image data to the target code size Qx. JPEG encoder 54 compresses image data read from image memory 53 with compression coefficient sx applied from compression coefficient estimating unit 71. The compressed data is transferred to recording apparatus 57. Such data compression method is disclosed, for example, in Japanese Patent Laying-Open No. 8-79762.
In this electronic still camera, compression coefficient sx is estimated without data compression, and JPEC compression is performed only once using the estimated compression coefficient sx. Therefore, as compared with the electronic still camera shown in FIG. 23 in which JPEG compression is performed three times, data compression takes shorter time.
However, in the electronic still camera shown in FIG. 28, image data generated by image capture device and image processing unit 52 is directly stored in image memory 53, so that image memory 53 must have large capacity, which leads to increased system cost.